package com.mlz.mlzmall.ui.sql;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import com.mlz.mlzmall.ui.utils.mlz.ConfigInfo;

/**
 * 本地数据库
 *
 */
public class DatabaseHelper extends SQLiteOpenHelper {

    //创建 用户表 SQL语句
    private String USER = "CREATE TABLE db_user (_id INTEGER PRIMARY KEY AUTOINCREMENT," +
            "userID VARCHAR(20), " +
            "user VARCHAR(20), " +
            "password VARCHAR(20)," +
            "userType INTEGER(2)," +
            "idCard VARCHAR(20)," +
            "phone VARCHAR(20)," +
            "email VARCHAR(20));";

    // 数据库版本号
    private static final int SQL_VERSION = 1;
    // 数据库名
    private static final String SQL_NAME = ConfigInfo.DB_NAME;

    public DatabaseHelper(Context context) {
        super(context, SQL_NAME, null, SQL_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //执行创建语句
        db.execSQL(USER);//创建用户表


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.i("数据库提示", "创建成功");
    }
}
